package com.kuang;

public class Person implements Cloneable{
    private int age;
    private String name;

    public Person(int age,String name){
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
       Person person  =  (Person)super.clone();
       person.name = new String(name);
       return person;
    }


    public static void main(String[] args) throws Exception {
        Person p = new Person(3,"xiaoming");
        Person p1 = p;
        Person p2 = (Person) p.clone();
        System.out.println(p);
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p2.getName() == p.getName());
    }

}

